﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Resources;
using System.Collections;
using System.Threading;

namespace displaycongress_desktop
{
    public partial class MainWindow : Form
    {
        private static string ip;
        private readonly string title = 
            "Welcome to Display Congress";
        private readonly string welcomeMessage = 
            "To create a new session, please click the 'Create Session' button.";
        private readonly string createSessionButtonText =
            "Create Session";

        public MainWindow()
        {
            InitializeComponent();
        }

        /*
         * Set all the appropiate texts of the MainWindow elements.
         */
        private void MainWindow_Load(object sender, EventArgs e)
        {
            titleLabel.Text = title;
            welcomeLabel.Text = welcomeMessage;
            createSessionButton.Text = createSessionButtonText;
        }

        private void createSessionButton_Click(object sender, EventArgs e)
        {
            Engine.showSessionScreen();
            LoginDecoder.setPassword(PasswordBox.Text);
            PasswordBox.Clear();
            // Create session dialog, or...?
        }

        private void testButton_Click(object sender, EventArgs e)
        {
            // Temp function. 
            
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void PasswordBox_TextChanged(object sender, EventArgs e)
        {
            LoginDecoder.setPassword(PasswordBox.Text);
        }

        public static void setIpAdres(String ipadres)
        {
            ip = ipadres;
        }

        private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Get result from MessageBox.
            DialogResult res = MessageBox.Show(this, "Are you sure you want to close?", "Closing", MessageBoxButtons.YesNo);

            // Confirm user wants to close
            switch (res)
            {
                case DialogResult.No:
                    e.Cancel = true;
                    break;
                default:
                    Engine.ApplicationExit();
                    break;
            }
        }
    }
}